import 'package:flutter/material.dart';
import 'home_screen.dart';

class SplashScreen extends StatelessWidget {
  const SplashScreen({super.key});

  @override
  Widget build(BuildContext context) {
    Future.delayed(const Duration(seconds: 2), () {
      Navigator.pushReplacement(
        context,
        MaterialPageRoute(builder: (context) => const HomeScreen()),
      );
    });

    return Scaffold(
      body: Container(
        decoration: const BoxDecoration(
          gradient: LinearGradient(
            colors: [Color(0xFF81D4FA), Color(0xFFB388FF), Color(0xFFFFF176)],
            begin: Alignment.topLeft,
            end: Alignment.bottomRight,
          ),
        ),
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(Icons.wb_sunny, size: 90, color: Colors.orangeAccent),
              const SizedBox(height: 24),
              const Text(
                '天气速览',
                style: TextStyle(
                  fontSize: 38,
                  fontWeight: FontWeight.bold,
                  color: Colors.white,
                  shadows: [Shadow(color: Colors.black26, blurRadius: 8)],
                ),
              ),
              const SizedBox(height: 16),
              const Text(
                '让天气一目了然',
                style: TextStyle(
                  fontSize: 20,
                  color: Colors.white70,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

// filepath: d:\workspaces\final_weather_app\lib\screens\home_screen.dart
class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('天气速览'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          children: [
            // 搜索框
            TextField(
              decoration: InputDecoration(
                hintText: '请输入城市名称',
                prefixIcon: Icon(Icons.search),
                border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
              ),
            ),
            const SizedBox(height: 20),
            // 当前天气信息（占位）
            Card(
              child: ListTile(
                leading: Icon(Icons.cloud, size: 40),
                title: Text('当前城市：北京'),
                subtitle: Text('晴  26°C  湿度: 40%'),
              ),
            ),
            const SizedBox(height: 20),
            // 未来7天天气预报（占位）
            Expanded(
              child: ListView.builder(
                itemCount: 7,
                itemBuilder: (context, index) {
                  return Card(
                    child: ListTile(
                      leading: Icon(Icons.wb_sunny),
                      title: Text('6月${index + 10}日'),
                      subtitle: Text('晴  最高30°C 最低20°C'),
                    ),
                  );
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}